package site.brood.user.pojo.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import site.brood.common.core.constant.Constants;
import site.brood.common.core.spring.SpringUtil;
import site.brood.common.core.str.StrUtil;
import site.brood.common.core.entity.BaseEntity;
import site.brood.user.mapper.UserMapper;
import site.brood.user.service.IUserService;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 用户信息
 */
@TableName("user")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User extends BaseEntity {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String deptId;
    private String username;
    private String nickname;
    private String email;
    private String phone;
    private String sex;
    private String avatar;
    private String password;
    private String status;
    private String deleted;
    private String loginIp;
    private LocalDateTime loginDate;
    private String createBy;
    private LocalDateTime createTime;
    private String updateBy;
    private LocalDateTime updateTime;
    private String remark;

    public boolean isAdmin()
    {
        IUserService userService = SpringUtil.getBean(IUserService.class);
        if(null == userService)
            return false;

        return userService.isAdmin(this.id);
    }
}
